// pages/plate/plate.js
// import Notify from '@vant/weapp/dist/notify/notify';
var api = require("../../config/api.js")
var app = getApp();
Page({
    data: {
      hot_articleList:[],
      activeKey:0,
      tag_10:[],
      shi_text:'',
      activeName:'',
        // activeKey: 0,
        // activeNames: ['1'],
        // active:['1'],
    },
    onChange2(event) {
      console.log(event.detail)
      this.setData({
        activeKey:event.detail
      })
      wx.request({
        url: api.PlateAPI,
        data: {
          tag_id:this.data.tag_10[this.data.activeKey].id
        },
        dataType: 'json',
        method: 'post',
        responseType: 'text',
        success: (result) => {
          this.setData({
            hot_articleList:result.data
          })
        },
        fail: (res) => {},
        complete: (res) => {},
      })
      // this.setData({

      // })
      // Notify({ type: 'primary', message: event.detail });
    },
      // 查看文章详情
  ViewDetails:function(e){
    var articleId = e.target.dataset.id
    console.log(e.target.dataset.id)
    wx.navigateTo({
      url: "../../pages/articledetail/articledetail?"+'articleId='+articleId,
    })
  },
    onChange3(event) {
      this.setData({
        activeName: event.detail,
      });
    },
  //   onChange1(event) {
  //       this.setData({
  //           activeNames: event.detail,
  //       });
  //   },
  // onChange(event) {
  //   // Notify({ type: 'primary', message: event.detail });
  // },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },
    all_tag_query:function(){
      wx.request({
        url: api.PlateAPI,
        data: '',
        dataType: 'json',
        method: 'GET',
        responseType: 'text',
        timeout: 0,
        success: (result) => {
          console.log(result.data)
          this.setData({
            tag_10:result.data
          })
          
        },
        fail: (res) => {},
        complete: (res) => {},
      })
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
      this.all_tag_query(),
      console.log(typeof(this.data.tag_10[0]))
      wx.request({
        url: 'https://v1.jinrishici.com/all.json',
        data: '',
        dataType: 'json',
        method: 'GET',
        responseType: 'text',
        timeout: 0,
        success: (result) => {
          console.log(result.data)
          this.setData({
            shi_text:result.data.content+' 作者:'+result.data.author+' 出处:'+result.data.origin
          })
        },
        fail: (res) => {},
        complete: (res) => {},
      })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})